/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package classcreator.classfillers;

import classcreator.ClassCreator;
import java.util.ArrayList;

/**
 *
 * @author Samus
 */
public class ABMConnection {

    private static ABMConnection instance = new ABMConnection();

    public static ABMConnection getInstance() {
        return instance;
    }

    private ABMConnection() {
    }

    public void addProps(ArrayList<String> clase) {
        String res = "private String userName = \"root\"";
        clase.add(res);
        res = "private String MySQLurl =\"jdbc:mysql://localhost/" + ClassCreator.getInstance().getPackagename() + "\";";
        clase.add(res);
        res = "private String password = \"\"";
        clase.add(res);
        clase.add("");
    }

    public void addDriverSupport(ArrayList<String> clase) {
        String res = "static {";
        clase.add(res);
        res = "try {";
        clase.add(res);
        res = "Class.forName(\"com.mysql.jdbc.Driver\");";
        clase.add(res);
        res = "} catch (ClassNotFoundException ex) {";
        clase.add(res);
        res = "Logger.getLogger(DataBaseConnFactory.class.getName()).log(Level.SEVERE, null, ex);";
        clase.add(res);
        res = "}";
        clase.add(res);
        clase.add(res);
        clase.add("");
    }

    public void addConnectionGiver(ArrayList<String> clase) {
        String res = "public Connection obtenerNewConexion() throws Exception {";
        clase.add(res);
        res = "Connection connection = DriverManager.getConnection(this.MySQLurl, userName, password);";
        clase.add(res);
        res = "return connection;";
        clase.add(res);
        res = "}";
        clase.add(res);
    }
}
